﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AMS.DD35.DbLoader.Controllers;

namespace AMS.DD35.DbLoader.Views
{
    public partial class ClassEditor : Form
    {
        private IClassController _controller;

        public bool EnableClassId
        {
            set { txtClassID.Enabled = value; }
        }

        public ClassEditor(IClassController controller)
        {
            InitializeComponent();

            this._controller = controller;
        }

        #region Populate Methods
        public void PopulateClassId(string id)
        {
            txtClassID.Text = id;
        }

        public void PopulateClassName(string name)
        {
            txtClassName.Text = name;
        }

        // ClassType

        // Fort

        // Ref

        // Will

        public void PopulateHitDieOptions(IEnumerable<object> options)
        {
            PopulateComboBox(cbHitDie, options);
        }

        public void PopulateSkillPointsOptions(IEnumerable<object> options)
        {
            PopulateComboBox(cbSkillPoints, options);
        }

        // Source

        private void PopulateComboBox(ComboBox cb, IEnumerable<object> options)
        {
            cb.Items.Clear();
            foreach (object o in options)
            {
                cb.Items.Add(o);
            }
        }

        // Class Features and Bonus Feats

        // Set Weapon Types

        // Weapons

        // Set Armor Types

        // Armors

        // Populate Shields

        // Set Shields

        // Populate Skills

        // Set Skills

        // Ethical Alignment Requisites

        // Moral Alignment Requisites

        // Spellcaster (not yet implmented)

        #endregion

        private void HandleBtnNewSource_Click(object sender, EventArgs e)
        {
            // have controller spawn SourceEditor
            _controller.BrowseSources();
        }

        private void HandleBtnAddBonusFeat_Click(object sender, EventArgs e)
        {
            // have controller spawn Browser keyed for Feats
            _controller.BrowseFeats();
        }

        private void HandleBtnAddClassFeature_Click(object sender, EventArgs e)
        {
            // have controller spawn Broswer keyed for Class Features
            _controller.BrowseClassFeatures();
        }

        private void HandleBtnAddWeapon_Click(object sender, EventArgs e)
        {
            // have controller spawn Browser keyed for Weapons
            _controller.BrowseWeapons();
        }

        private void HandleBtnAddArmor_Click(object sender, EventArgs e)
        {
            // have controller spawn Browser keyed for Armor
            _controller.BrowseArmors();
        }

        private void HandleBtnNewShield_Click(object sender, EventArgs e)
        {
            // have controller spawn Shield Editor
            _controller.SpawnShieldEditor();
        }

        private void HandleBtnNewSkill_Click(object sender, EventArgs e)
        {
            // have controller spawn Skill Editor
            _controller.SpawnSkillEditor();
        }

        private void HandleBtnSpellPerDay_Click(object sender, EventArgs e)
        {
            // have controller spawn Spells Per Day dialog
            _controller.SpawnSpellsPerDayDialog();
        }

        private void HandleBtnSpellsKnown_Click(object sender, EventArgs e)
        {
            // have controller spawn Spells Known dialog
            _controller.SpawnSpellsKnownDialog();
        }

        private void HandleBtnCancelQuitClose_Click(object sender, EventArgs e)
        {
            // have controller close this
            _controller.Close();
        }

        private void HandleBtnSave_Click(object sender, EventArgs e)
        {
            // have controller save new or changes to DB, populate ID if new
            _controller.Save();
        }
    }
}
